/**
 * Captain
 * © 2018 Captain copyright，All rights reserved.
 * http://www.sccaptain.com.cn
 * 
 * JAVA : 8
 * 文  件  名: OrderFormController.java
 * 创  建  人: QinYoubin (qin.youbin@sccaptain.com.cn)
 * 创建时间: 2018年5月2日 下午2:13:19
 * 版         本: 1.0.0
 * 备         注:
 * 修订历史:
 */
package com.material.c2c.web.shopping.controller;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.cpt.framework.web.JsonResult;
import com.material.c2c.shoping.service.OrderFormService;
import com.material.c2c.web.commodity.model.CommQuery;
import com.material.c2c.web.shopping.model.OrderFormVO;
import com.material.c2c.web.util.ControllerUtil;

/**
 * 购物订单控制层
 * @since 1.0
 * @version 1.0
 * @author QinYoubin (qin.youbin@sccaptain.com.cn)
 */
@RestController
@RequestMapping("/orderForm")
public class OrderFormController {
  @Resource
  private OrderFormService orderFormService;
  
  @PostMapping("/add")
  public JsonResult add(@RequestBody OrderFormVO vo) {
    //新增订单
    return JsonResult.success(orderFormService.add(vo.getGwdd(), vo.getMapList(),vo.getCartList()));
  }
  @GetMapping("/list/{id}/{ddzt}")
  public JsonResult list(@PathVariable String id,@PathVariable int ddzt) {
    // 根据用户查询订单
    return JsonResult.success(orderFormService.list(id,ddzt));
  }
  @GetMapping("/cancel/{id}")
  public JsonResult cancel(@PathVariable String id) {
	  return ControllerUtil.getResult(orderFormService.cancel(id));
  }
  @GetMapping("/getOne/{id}")
  public JsonResult getOne(@PathVariable String id) {
	  return JsonResult.success(orderFormService.getOne(id));
  }
  // 完成支付
  @GetMapping("/paid/{id}/{zffs}")
  public JsonResult paid(@PathVariable String id,@PathVariable String zffs) {
	  return ControllerUtil.getResult(orderFormService.paid(id, zffs));
  }
  @PostMapping("/getPage")
  public JsonResult getPage(@RequestBody CommQuery query) {
	  return JsonResult.success(orderFormService.getPage(query.getZt(), query.getPageable()));
  }
  @GetMapping("/changeStatus/{id}/{zt}")
  public JsonResult changeStatus(@PathVariable String id,@PathVariable int zt) {
	  return ControllerUtil.getResult(orderFormService.changeStatus(id, zt));
  }
}
